package org.example.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.commonapi.domain.ExamQuestions;
import org.example.commonapi.domain.R;
import org.example.course.service.ExamQuestionsService;
import org.example.commonapi.mapper.ExamQuestionsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author DELL
* @description 针对表【exam_questions(考试题目)】的数据库操作Service实现
* @createDate 2024-06-28 19:21:50
*/
@Service
public class ExamQuestionsServiceImpl extends ServiceImpl<ExamQuestionsMapper, ExamQuestions>
    implements ExamQuestionsService{

    @Autowired
    private ExamQuestionsMapper examQuestionsMapper;


    @Override
    public R<String> submitAnswer(String answer, Integer id) {
        LambdaQueryWrapper<ExamQuestions> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ExamQuestions::getId, id);
        ExamQuestions examQuestions = examQuestionsMapper.selectOne(wrapper);
        if (examQuestions.getAnswer().equals(answer)) {
            return R.success("正确");
        }else {
            return R.success("错误");
        }
    }


    /**
     * todo 提交答案(直接计算分数)
     * @param answer
     * @param id
     */
    @Override
    public void submitAnswer(List<String> answer, Integer id) {

    }
}




